﻿using System.Linq;
using Framework.Exceptions;
using Interfaces.Validation;
using Interfaces.Validation.Repositories;

namespace SQLRepositories.ValidationRepository
{
    public class UserValidationRepository : BaseRepository ,IUserValidationRepository
    {
        public UserValidationRepository(IDBEconomicInformationServiceContext context) 
            : base(context)
        {}

        public bool IsEmailExists(string email)
        {
           return ExceptionHandlingManager.Process(()=>Context.Users.Any(x => x.Email.Equals(email)),PolicyNames.DALPolicy);
        }

        public bool IsUserNameExists(string userName)
        {
            return ExceptionHandlingManager.Process(()=>Context.Users.Any(x => x.UserName.Equals(userName)),PolicyNames.DALPolicy);
        }
    }
}
